package com.moon.config;

import com.moon.interceptor.AuthcInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

//@Configuration
public class InterceptorConfig extends WebMvcConfigurerAdapter {
    @Autowired
    private AuthcInterceptor authcInterceptor;

//    @Autowired
//    private AntiReLoginInterceptor antiReLoginInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //排除路径(不被拦截的路径)
        String[] excludes={"/**/*login*/**", "/**/*register*/**", "/**/*success*/**", "/**/*error*/**"};
//        String[] excludes={"/**"};

        //添加拦截器  拦截所有路径 排除excludes路径
        registry.addInterceptor(authcInterceptor).addPathPatterns("/**").excludePathPatterns(excludes);
//        registry.addInterceptor(antiReLoginInterceptor).addPathPatterns("/**").excludePathPatterns(excludes);
        super.addInterceptors(registry);
    }
}
